package com.pan.behavioral.Interpreter.example.ex01.expression.impl;

import com.pan.behavioral.Interpreter.example.ex01.context.Context;
import com.pan.behavioral.Interpreter.example.ex01.expression.Expression;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;

public class MyExpression implements Expression {
    List<Expression> expressionList;{

        expressionList = new LinkedList<>();
    }

    Pattern loopPattern = Pattern.compile("^\\s*loop\\s*\\d+");
    Pattern funcPattern = Pattern.compile("^\\s*func\\s+\\w+\\((\\s*|\\w+|(\\w+,)+\\w+)\\)");
    Pattern varPattern = Pattern.compile("^\\s*var\\s+\\w+\\s*=\\s*[.]+");
    Pattern ifPattern = Pattern.compile("^\\s*if\\s*\\(.+\\)");

    @Override
    public void interpreter(Context context) {
    }

    @Override
    public String execute() {
        Iterator<Expression> iterator = expressionList.iterator();
        for (;iterator.hasNext();){
            iterator.next().execute();
        }
        return null;
    }
}
